/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package helpers;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;

/**
 *
 * @author arnaldo
 */
public class HandleStrings {

    public static void main(String[] args) {

        try {

            FileWriter fstreamout = new FileWriter("LastNamesFinal.txt");
            BufferedWriter out = new BufferedWriter(fstreamout);

            FileInputStream fstream = new FileInputStream("lastnames.txt");
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            
            String strLine;

            //Read File Line By Line
            while ((strLine = br.readLine()) != null) {
                out.write(strLine.split(" ")[0] + "\n");
            }

            out.close();
            in.close();
            
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }

    }
}
